package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportRecordCheckDto;
import com.yqg.protection.entity.RecordCheck;
import com.yqg.protection.mapper.RecordCheckMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/15 9:49
 * description:
 */
@Component
public class RecordCheckListener extends AnalysisEventListener<ImportRecordCheckDto> {

    @Autowired
    private RecordCheckMapper recordCheckMapper;

    @Override
    public void invoke(ImportRecordCheckDto importRecordCheckDto, AnalysisContext analysisContext) {
        RecordCheck recordCheck = new RecordCheck();
        BeanUtil.copyProperties(importRecordCheckDto, recordCheck, true);
        recordCheck.setIsDelete(0);
        recordCheckMapper.insert(recordCheck);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
